package com.tale.springbootatm.common.config;

import com.tale.springbootatm.common.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * author: 蔡奇峰
 * date: 2020/5/2 10:27
 **/
@Configuration
public class RabbitMqConfig {


    @Bean
    public Queue mailQueue(){

        return new Queue(RabbitConstant.MAIL_QUEUE);
    }

    @Bean
    public TopicExchange mailExchange(){

        return new TopicExchange(RabbitConstant.MAIL_EXCHANGE);
    }


    @Bean
    public Binding mailBinding(){

        return BindingBuilder.bind(mailQueue()).to(mailExchange()).with(RabbitConstant.MAIL_ROUTE_KEY);
    }



}
